#include "ResourceManagers.h"


ImageManager* ImageManager::Instance(){

		static ImageManager instance;
		return &instance;
}

Image* ImageManager::GetImage(string name){


	map<string,Image*>::iterator it=images.find(name);

	if(it!=images.end())
		return it->second;
	else{
		Image * img= new Image();
		img->LoadFromFile(name);
		img->SetSmooth(false);
		images[name]=img;
		return img;
	}



}



FontManager* FontManager::Instance(){

		static FontManager instance;
		return &instance;
}

Font* FontManager::GetFont(string name){


	map<string,Font*>::iterator it=fonts.find(name);

	if(it!=fonts.end())
		return it->second;
	else{
		Font * font= new Font();
		font->LoadFromFile(name);
		fonts[name]=font;
		return font;
	}



}


SoundBufferManager* SoundBufferManager::Instance(){

		static SoundBufferManager instance;
		return &instance;
}

SoundBuffer* SoundBufferManager::GetBuffer(string name){


	map<string,SoundBuffer*>::iterator it=buffers.find(name);

	if(it!=buffers.end())
		return it->second;
	else{
		SoundBuffer * buffer= new SoundBuffer();
		buffer->LoadFromFile(name);
		buffers[name]=buffer;
		return buffer;
	}



}
